# -*- coding: utf-8 -*-
"""
 @Time    : 2021/2/22 下午6:16
 @Author  : tgy
 
"""


def reverse_stack(stack: list):
    ...
    do_reversal(stack)


def get_first(stack: list):
    ...
    if len(stack) == 1:
        return stack.pop()
    val = stack.pop()
    first_val = get_first(stack)
    stack.append(val)
    return first_val


def do_reversal(stack: list):
    ...
    val = get_first(stack)
    if len(stack):
        do_reversal(stack)
    stack.append(val)


if __name__ == '__main__':
    ...
    stack = [1, 2, 3, 4, 5]
    reverse_stack(stack)
    print(stack)
